home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Installer SDK Cornucopia 1.0.2 / Script Examples / System Rules / sysRules.r < prev    next >
Encoding:
Text File  |  1996-09-30  |  11.7 KB  |  421 lines  |  [TEXT/MPS ]

  1. //
  2. //    appRules.r
  3. //
  4. //        This example demonstrates usage of the Easy and Custom Install 
  5. //        frameworks for use in installing a file.
  6. //
  7. //        System version screening, as well as customized user interface and 
  8. //        installation contents based on existing system version of selected 
  9. //        target volume are included.
  10. //
  11. //        All files are installed to folder "System Rules App Example:" on 
  12. //        root folder of selected target volume for the installation.
  13. //
  14. //        Copyright 1993-1996, Apple Computer, Inc., All Rights Reserved
  15. //
  16.  
  17. #include "InstallerTypes.r"
  18.  
  19.  
  20. // constants for packages, comments, comment text
  21. #define     k75Package            100
  22. #define     k70Package            200
  23. #define     kSeperatorLine        9999
  24.  
  25. // target spec of system file for comparing system versions
  26. #define     kSystemFileTarget     20001
  27.  
  28.  
  29.  
  30.  
  31. // • easy install setup
  32.  
  33. // easy install framework uses ID other than 765 or 766
  34. // recommended to always use ID 764
  35. resource 'infr' (764) {
  36.     format0 {{
  37.         // execute first true rule, if none are true then return false
  38.         pickFirst, { 700, 800, 900 }, // check system version, if bad give error
  39.     }}
  40. };
  41.  
  42. // rule that adds 7.5 or greater compatable file to Easy Install
  43. resource 'inrl' (700) {
  44.     format0 {{
  45.         // check for 7.5 or greater
  46.         CheckFileVersion{ kSystemFileTarget, 7, 5, release, 0 },
  47.         
  48.         // if 7.5 or greater add that package
  49.         AddPackages{{ k75Package }},
  50.         AddUserDescription{ "Install Example File for 7.5" },
  51.     }}
  52. };
  53.  
  54. // rule that adds 7.0 or greater compatable file to Easy Install
  55. resource 'inrl' (800) {
  56.     format0 {{
  57.         // check for 7.0 or greater
  58.         CheckFileVersion{ kSystemFileTarget, 7, 0, release, 0 },
  59.         
  60.         // if 7.0 or greater add that package
  61.         AddPackages{{ k70Package }},
  62.         AddUserDescription{ "Install Example File for 7.0" },
  63.     }}
  64. };
  65.  
  66.  
  67. // • custom install setup
  68.  
  69. // custom install framework always uses ID of 766
  70. resource 'infr' (766) {
  71.     format0 {{
  72.         pickFirst, { 1000, 900 },  // check system version, if bad give error
  73.     }}
  74. };
  75.  
  76. // rule that checks system version of target volume
  77. resource 'inrl' (1000) {
  78.     format0 {{
  79.         // this returns false unless system version is greater than 7.0
  80.         CheckFileVersion{ kSystemFileTarget, 7, 0, release, 0 },
  81.         AddCustomItems{{ k75Package, kSeperatorLine, k70Package }},
  82.     }}
  83. };
  84.  
  85. // • used in both easy and custom
  86. resource 'inrl' (900) {
  87.     format0 {{
  88.         ReportVolError{ "System 7.0 or greater required for installation !!" }
  89.     }}
  90. };
  91.  
  92.  
  93. // • packages
  94.  
  95. // 7.5 or greater
  96. resource 'inpk' ( k75Package ) {
  97.     format0 {
  98.         showsOnCustom,    // if a subpackage, then show in Custom Install
  99.         removable,        // include package or subpackage as a removeable item
  100.         dontForceRestart,// don't make user reboot his computer after install
  101.         k75Package,        // ID of package comments ( 'inpc' ) rsrc defined below
  102.         0,                // Package size ( if 0, filled in by ScriptCheck )
  103.         
  104.         "Example File for 7.5",        
  105.                         // Custom Install selection text
  106.                                 
  107.                                 
  108.         {                // Package parts list ( all the stuff to be included 
  109.                         // in package ) These parts can be 'inpk', 'infa', 'inra', 
  110.                         // 'inr#', 'inrm', 'inff', 'infm', 'inaa', 'inat', 'inat', 
  111.                         // or 'inbb'
  112.                                                                 
  113.         'infa', 1075;    // 7.5 compatable file
  114.         },
  115.     }
  116. };
  117.  
  118.  
  119. // seperator line in Custom Install list of options
  120. resource 'inpk' ( kSeperatorLine ) {
  121.     format0 {
  122.         showsOnCustom,    // if a subpackage, then show in Custom Install
  123.         removable,        // include package or subpackage as a removeable item
  124.         dontForceRestart,// don't make user reboot his computer after install
  125.         0,                // no comments for a seperator line
  126.         0,                // no size for a seperator line
  127.         "-",            // display dashed line in Custom Install list of options
  128.         {    
  129.                         // parts list is empty for seperator line
  130.         },
  131.     }
  132. };
  133.  
  134. // 7.0 or greater
  135. resource 'inpk' ( k70Package ) {
  136.     format0 {
  137.         showsOnCustom,    // if a subpackage, then show in Custom Install
  138.         removable,        // include package or subpackage as a removeable item
  139.         dontForceRestart,// don't make user reboot his computer after install
  140.         k70Package,        // ID of package comments ( 'inpc' ) rsrc defined below
  141.         0,                // Package size ( if 0, filled in by ScriptCheck )
  142.         
  143.         "Example File for 7.0",        
  144.                         // Custom Install selection text
  145.                                 
  146.                                 
  147.         {                // Package parts list ( all the stuff to be included 
  148.                         // in package ) These parts can be 'inpk', 'infa', 'inra', 
  149.                         // 'inr#', 'inrm', 'inff', 'infm', 'inaa', 'inat', 'inat', 
  150.                         // or 'inbb'
  151.                                                                 
  152.         'infa', 1070;    // 7.0 compatable file
  153.         },
  154.     }
  155. };
  156.  
  157.  
  158.  
  159. // • package comments
  160.  
  161. // NOTE: The file that will be installed by either package is actually 
  162. // a bogus test Example File. It does not really include any information for
  163. // 7.0 or 7.5.  In addition, the information detailed below does not
  164. // actually correspond to the file being installed and is intended only
  165. // as an example of how to prepare custom package information resources.
  166.  
  167. // FURTHER NOTE: The values that are assigned to the Custom Package Information 
  168. // resource fields do not actually have any effect on the installation and are ignored
  169. // during installation. They can however assist the user in choosing which 
  170. // packages they would like to include in their Custom Installation or Custom 
  171. // Removal.
  172.  
  173. //     The following included file contains the icons for the two package comments.
  174. //     The file with the icon resources ( 'ICN#', 'icl4' and 'icl8' ) was created
  175. //     by doing a "Get Info" (from File menu in Finder) on the Example File file to be
  176. //  installed. Then, the Example File icon in the "Get Info" dialog was selected,
  177. //  copied, and then pasted into a new ResEdit file  called "Icons.rsrc".  All
  178. //  icon resources were then deleted except for the 'ICN#', 'icl4' and 'icl8' icon
  179. //  resources.  These remaining resource items were assigned an ID of 9128, since
  180. //  their original resource ID's had a value that was illegal for use with 'inpc'
  181. //  resources ( they must be over 1024 ).
  182.  
  183. include "Icons.rsrc";
  184.  
  185. resource 'inpc' ( k75Package ) {
  186.     format1 {
  187.         9261996,                // sample date ( 08/02/94 )
  188.         403,                    // sample version ( 4.0.3 )
  189.         
  190.         2500 * 1024,            // RAM required for package ( 2.5 megabytes )
  191.         
  192.         9128,                    // icon rsrc ID ( 'ICN#', 'icl4', 'icl8' )
  193.                                 // - ID must be greater than 1024
  194.                                 // - resource item in rezzed script file
  195.                                 
  196.         k75Package,                // 'TEXT' resource ID of item  
  197.                                 // containing package description
  198.         
  199.     }
  200. };
  201.  
  202. resource 'inpc' ( k70Package ) {
  203.     format1 {
  204.         9261996,                // sample date ( 08/02/94 )
  205.         403,                    // sample version ( 4.0.3 )
  206.  
  207.         4250 * 1024,            // RAM required for package ( 4.25 megabytes )
  208.         
  209.         9128,                    // icon rsrc ID ( 'ICN#', 'icl4', 'icl8' )
  210.                                 // - ID must be greater than 1024
  211.                                 // - resource item in rezzed script file
  212.  
  213.         k70Package,            // 'TEXT' resource ID of item  
  214.                                 // containing package description
  215.     }
  216. };
  217.  
  218.  
  219. // The following resource items can easily be created manually by creating 'TEXT' 
  220. //  resource items in a file and including that file in this script.
  221. // USE: include "fileWithTextItem.rsrc";    
  222. // NOTE : resource includes use "include" instead of "#include" 
  223. //         and are terminated with a semicolon.
  224. data 'TEXT' ( k75Package ) {
  225.     "This is some sample text that would describe what "
  226.     "the 7.5 compatible package contains."
  227. };
  228.  
  229. data 'TEXT' ( k70Package ) {
  230.     "This is some sample text that would describe what "
  231.     "the 7.0 compatible package contains."
  232. };
  233.  
  234.  
  235.  
  236. // • file atoms
  237.  
  238. // file atom for extension
  239. resource 'infa' (1075) {
  240.     format1 {
  241.         deleteWhenRemoving,
  242.         deleteWhenInstalling,
  243.         copy,                        
  244.         dontIgnoreLockedFile,
  245.         dontSetFileLocked,
  246.         useSrcCrDateToCompare,        
  247.         srcNeedExist,
  248.         rsrcForkInRsrcFork,
  249.         leaveAloneIfNewer,            
  250.         updateExisting,                
  251.         copyIfNewOrUpdate,
  252.         rsrcFork,
  253.         dataFork,
  254.         0,
  255.         0x0,
  256.         10075,
  257.         {    
  258.             10076, 
  259.             0, 
  260.             0    
  261.         },
  262.         0,                            
  263.         0,
  264.         0,
  265.         "Example File • 7.5"
  266.     }
  267. };
  268.  
  269. // file atom for extension
  270. resource 'infa' (1070) {
  271.     format1 {
  272.         deleteWhenRemoving,
  273.         deleteWhenInstalling,
  274.         copy,                        
  275.         dontIgnoreLockedFile,
  276.         dontSetFileLocked,
  277.         useSrcCrDateToCompare,        
  278.         srcNeedExist,
  279.         rsrcForkInRsrcFork,
  280.         leaveAloneIfNewer,            
  281.         updateExisting,                
  282.         copyIfNewOrUpdate,
  283.         rsrcFork,
  284.         dataFork,
  285.         0,
  286.         0x0,
  287.         10070,
  288.         {    
  289.             10071, 
  290.             0, 
  291.             0    
  292.         },
  293.         0,                            
  294.         0,
  295.         0,
  296.         "Example File • 7.0"
  297.     }
  298. };
  299.  
  300.  
  301. // • file specs
  302.  
  303. // target file spec  Example File for 7.5
  304. resource 'intf' (10075) {
  305.     format1 {
  306.         noSearchForFile,             // use default search path
  307.         
  308.         TypeCrMustMatch,             // If this is set to TypeCrMustMatch
  309.                                     // then a file with a different type
  310.                                     // and creator than those specified
  311.                                     // below will not be replaced.
  312.                                     // If this is set to TypeCrNeedNotMatch
  313.                                     // then type and creator of an existing
  314.                                     // target file are ignored.
  315.         
  316.         // The Type and Creator fields will be used to set the
  317.         // file's Type and Creator when a new file is created. 
  318.         'ttro',                     // TYPE for new file
  319.         'ttxt',                     // CREATOR for new file
  320.         
  321.         0,                             // finder attribute flags
  322.                                     // filled by ScriptCheck is value is 0
  323.         
  324.         1,                              // creation date for new file
  325.         1,                              // modification date for new file
  326.                                     // NOTE: DATE values are filled
  327.                                     // by ScriptCheck if the value is 1
  328.                                             
  329.         0,                             // search proc ID ( 'insp' ), none used
  330.         
  331.         ":System Rules Example:Example File • 7.5" // path to target file
  332.         }
  333.     };
  334.  
  335. // source file spec for Example File for 7.5
  336. resource 'infs' (10076) {
  337.     'ttro',                    // TYPE for file search
  338.     'ttxt',                    // CREATOR for file search
  339.     
  340.     0x1,                    // creation DATE for source file
  341.                             // ( value of 1, filled in by ScriptCheck
  342.                                 
  343.     noSearchForFile,        // IGNORED in Installer 4.0.x
  344.     TypeCrMustMatch,        // TYPE, CREATOR must match file on install disk
  345.     "Disk 1:Example File • 7.5"    // PATH to source file        
  346. };
  347.  
  348.  
  349. // target file spec for Example File for 7.0
  350. resource 'intf' (10070) {
  351.     format1 {
  352.         noSearchForFile,             // use default search path
  353.         
  354.         TypeCrMustMatch,             // If this is set to TypeCrMustMatch
  355.                                     // then a file with a different type
  356.                                     // and creator than those specified
  357.                                     // below will not be replaced.
  358.                                     // If this is set to TypeCrNeedNotMatch
  359.                                     // then type and creator of an existing
  360.                                     // target file are ignored.
  361.         
  362.         // The Type and Creator fields will be used to set the
  363.         // file's Type and Creator when a new file is created. 
  364.         'ttro',                     // TYPE for new file
  365.         'ttxt',                     // CREATOR for new file
  366.         
  367.         0,                             // finder attribute flags
  368.                                     // filled by ScriptCheck is value is 0
  369.         
  370.         1,                              // creation date for new file
  371.         1,                              // modification date for new file
  372.                                     // NOTE: DATE values are filled
  373.                                     // by ScriptCheck if the value is 1
  374.                                             
  375.         0,                             // search proc ID ( 'insp' ), none used
  376.         
  377.         ":System Rules Example:Example File • 7.0" // path to target file
  378.         }
  379.     };
  380.  
  381. // source file spec for TeachText application for 7.0
  382. resource 'infs' (10071) {
  383.     'ttro',                    // TYPE for file search
  384.     'ttxt',                    // CREATOR for file search
  385.     
  386.     0x1,                    // creation DATE for source file
  387.                             // ( value of 1, filled in by ScriptCheck
  388.                                 
  389.     noSearchForFile,        // IGNORED in Installer 4.0.x
  390.     TypeCrMustMatch,        // TYPE, CREATOR must match file on install disk
  391.     "Disk 1:Example File • 7.0"    // PATH to source file        
  392. };
  393.  
  394.  
  395.  
  396. // target file spec for checking System version on target
  397. resource 'intf' ( kSystemFileTarget ) {
  398.     format1 {
  399.         noSearchForFile,             // use default search path
  400.         
  401.         TypeCrMustMatch,             // If this is set to TypeCrMustMatch
  402.                                     // then a file with a different type
  403.                                     // and creator than those specified
  404.                                     // below will not be found when this
  405.                                     // target spec is referenced from
  406.                                     // within the rules framework.
  407.         
  408.         'zsys',                     // TYPE for file
  409.         'MACS',                     // CREATOR for file
  410.         
  411.         0,                             // finder attribute flags
  412.         
  413.         1,                              // creation date
  414.         1,                              // modification date
  415.                                             
  416.         0,                             // search proc ID ( 'insp' ), none used
  417.         
  418.         "special-macs:System"    // path to target file
  419.         }
  420.     };
  421.